# Makefile for recycle lib
 
CC=clang # Better error messages
#CC=gcc
CFLAGS= -W -Wall -Werror -std=c99 -O2
LDFLAGS=
 
SRCCAT= cat.c
OBJCAT= ${SRCCAT:.c=.o}

SRCFS=filesplit.c
OBJFS= ${SRCFS:.c=.o}

SRCGF= genfile.c
OBJGF= ${SRCGF:.c=.o}

SRCSK= seek.c
OBJSK= ${SRCSK:.c=.o}

SRCST= stat.c
OBJST= ${SRCST:.c=.o}

EXECS = mycat mysplit mygenfile myseek mylstat

CLEAN = rm -f 
OBJ=*~ *.o


all : fullclean ${EXECS} clean
	@echo " "
	@echo "Build done. Testing :"
	@echo "---------------------"
	@echo " "
	@echo " "
	./mygenfile testfile
	@echo " "
	./mycat testfile
	@echo " "
	./myseek testfile y
	@echo " "
	@echo " "
	-mkdir test
	@echo " "
	./mysplit testfile 1 test/result
	@echo " "
	-ls test/
	@echo " "
	./mylstat testfile
	@echo " "
	-rm -rf test/ testfile
	@echo " "
	@echo "To know how to use each function, use \"-h\" (or --help)"
	@echo "Made by dumont_h (Matthieu Dumont)"

mycat: ${OBJCAT}
	${CC} ${LDFLAGS} -o $@ ${OBJCAT}

mysplit: ${OBJFS}
	${CC} ${LDFLAGS} -o $@ ${OBJFS}

mygenfile: ${OBJGF}
	${CC} ${LDFLAGS} -o $@ ${OBJGF}

myseek: ${OBJSK}
	${CC} ${LDFLAGS} -o $@ ${OBJSK}
	
mylstat: ${OBJST}
	${CC} ${LDFLAGS} -o $@ ${OBJST}

clean::
	${CLEAN} ${OBJ}

fullclean::
	${CLEAN} ${OBJ} ${EXECS}
 
# END
